package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.guguoxunbao.GuGuoXunBaoMgr;

public class GuGuoXunBaoRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        if (GuGuoXunBaoMgr.activityInTime()) {
            ActivityInfo activityInfo = GuGuoXunBaoMgr.getActivityInfo();
            long recycleTime = activityInfo.getEndShowTime() * 1000L + gapTime;
            ActivityItemRecycleMgr.addRecycleItemData(GuGuoXunBaoMgr.CAMEL_ID, activityType, recycleTime);
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.GuGuoXunBaoActivity.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        int itemId = data.getItemId();
        UserBagItem userBagItem = getUserBagItem(userId, itemId);
        if (userBagItem != null && userBagItem.getNum() > 0) {
            removeItem(userBagItem);
        }
    }

    @Override
    public boolean isActivityRunning() {
        ActivityInfo activityInfo = GuGuoXunBaoMgr.getActivityInfo();
        return ActivityMgr.activityInTime(activityInfo);
    }
}
